{% extends "forum/base.html" %}
{% load i18n %}

{% block body %}

<div class="space">
    {% ifequal fg_list.count 0 %}
    <p>
        <em>
        {% blocktrans %}
        There are no forum groups (the stuff where foruns are placed) registered 
        within this application at the moment.
        {% endblocktrans %}
        </em>
    </p>
    
    {% if user.is_staff %}
    <em>
        {% blocktrans %}
        Go to the menu above and register a few groups. Then, register a 
        few foruns for those groups.
        {% endblocktrans %}
    </em>
    {% endif %}
    {% endifequal %}
    
    {% for forum_group in fg_list %}
    
    <table class="foruns">
        <thead>
            <tr>
                <th class="col1 forumcell-name">{{forum_group|capfirst}}</th>
                <th class="col2 forumcell-topics">{% trans "Topics" %}</th>
                <th class="col3 forumcell-posts">{% trans "Replies" %}</th>
                <th class="col4 forumcell-lastpost last">{% trans "Last Topic"%}</th>
            </tr>
        </thead>
        <tbody>
            {% for forum in forum_group.forum_list.all %}
            <tr {% if forloop.counter|divisibleby:2 %} class="mark" {%endif%}>
                <td class="span-12 forumcell-name">
                    <a href="{{ forum.link }}">{{forum}}</a>
                    <div class="clear small" style="margin-bottom: 0px;">
                        <span class="quiet">{{forum.short}}</span>
                    </div>
                </td>
                <td class="span-3 forumcell-topics">{{forum.topic_count}}</td>
                <td class="span-3 forumcell-posts">{{forum.reply_count}}</td>
                <td class="span-6 forumcell-lastpost last">
                    {% with forum.latest_topic as latest_topic %}
                        {% if latest_topic %}
                        <a href="{{latest_topic.link}}">{{latest_topic.title|wordwrap:5}}</a> by <br />
                        <a href='{% url forum-user-profile latest_topic.username %}'>{{latest_topic.username}}</a>
                        at {{latest_topic.created_time|date}}

                        {% else %}
                        <span>{% trans "No topic found" %}</span>
                        {% endif %}                    
                    {% endwith %}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    
    {% endfor %}
    {# for forum in main_foruns #}
</div>
{% endblock body %}